package com.infore.airsupervise.ui.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 禁止滑动、无动画效果的ViewPager
 *
 * @author: dingxinlin
 * @date: 2016-10-17 11:25
 */
public class NoScrollViewPager extends ViewPager {

    public NoScrollViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        // 禁止滑动
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        // 禁止滑动
        return false;
    }

    @Override
    public void setCurrentItem(int item) {
        // 去除页面切换时的滑动翻页效果
        super.setCurrentItem(item, false);
    }

    @Override
    public void setCurrentItem(int item, boolean smoothScroll) {
        // 去除页面切换时的滑动翻页效果
        super.setCurrentItem(item, false);
    }
}
